package ink.xiaobaibai.common;

import com.fasterxml.jackson.annotation.JsonProperty;
import ink.xiaobaibai.util.WxPayKeyInfo;
import lombok.Data;

import java.util.UUID;

/**
 * @description: 调起微信支付对象
 * @author: 小白白
 * @create: 2021-05-21
 **/

@Data
public class WxPayment {

    public WxPayment(String prepareWxOrder) {
        this.prepareWxOrder = prepareWxOrder;
        this.nonceStr = UUID.randomUUID().toString().substring(0, 32);
        this.timeStamp = System.currentTimeMillis() / 1000;
        this.paySign = WxPayKeyInfo.signTwo(WxCommon.APPID, this.timeStamp, this.nonceStr, this.prepareWxOrder, WxPayKeyInfo.getPKCS12());
    }

    @JsonProperty(value = "package")
    private String prepareWxOrder;

    private String nonceStr;

    private Long timeStamp;

    private String paySign;

}
